package com.itheima.ioTest_2;

import java.io.*;
import java.util.ArrayList;

public class testUnicod5 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("IO\\a.txt"));
        user u=new user();
        u.setUesrname("zhangshan");
        u.setPassword("122334");
        user u1=new user("王五","252525");
        user u2=new user("李四","242424");
        user u3=new user("张三","232323");
        oos.writeObject(u);
        oos.writeObject(u1);
        oos.writeObject(u2);
        oos.writeObject(u3);

        ObjectInputStream ois=new ObjectInputStream(new FileInputStream("IO\\a.txt"));
        // ArrayList<user> list=new ArrayList<>();
        /*list.add(u1);
        list.add(u2);
        list.add(u3);*/
        while (true){
            try {
                user o =(user) ois.readObject();
                System.out.println(o.getUesrname()+"--"+o.getPassword());
            } catch (EOFException e) {
                break;
            }
        }
        oos.close();
    }
}


